<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

//Models
Route::model('traveler', 'Traveler');
Route::model('user', 'User');

Route::get('/',
		array(
			'as' => 'travelers.index',
			'uses' => 'TravelersController@index'
		)
);

Route::get('/add', 'TravelersController@add');
Route::post('/add', 'TravelersController@add');

Route::post('/save', 'TravelersController@handleAdd');
Route::post('/send', 'TravelersController@send');

Route::get('/admin/usuarios/autenticacao', 'UsersController@login');
Route::post('/admin/usuarios/login', 'UsersController@handleLogin');

Route::get('/admin/usuarios/proibido', 'UsersController@forbidden');


Route::group(array('before' => 'auth'), function()
{
	Route::get('/admin/viajantes', 'TravelersController@all');
	Route::get('/admin/viajantes/info/{traveler}', 'TravelersController@info');
	Route::get('/admin/viajantes/status/{traveler}', 'TravelersController@status');
	Route::post('/admin/viajantes/search', 'TravelersController@search');
	Route::get('/admin/usuarios/logout', 'UsersController@logout');
	
	Route::group(array('before' => 'auth.admin'), function()
	{
		Route::get('/admin/usuarios', 'UsersController@index');
		Route::get('/admin/usuarios/add', 'UsersController@add');
		Route::get('/admin/usuarios/edit/{user}', 'UsersController@edit');
		Route::get('/admin/usuarios/delete/{user}', 'UsersController@delete');
		
		Route::post('/admin/usuarios/save', 'UsersController@handleAdd');
		Route::post('/admin/usuarios/edit', 'UsersController@handleEdit');
		Route::post('/admin/usuarios/delete', 'UsersController@handleDelete');
	});
	
});